package enums;

import java.util.HashMap;
import java.util.Map;

/**
 * Indicating the type a purchase is paid.
 */
public enum PaymentType {

	CASH(1), INVOICE(0);
	
	
	private final int paymentInt;
	
	/**
	 * Map of all existing Messages
	 */
	private static final Map<Integer, PaymentType> intToPayment = new HashMap<>();

	static {
		for (PaymentType f : PaymentType.values()) {
			intToPayment.put(f.toInt(), f);
		}
	}

	private PaymentType(int paymentInt) {
		this.paymentInt = paymentInt;
	}

	public Integer toInt() {

		return paymentInt;
	}

	public static PaymentType fromInt(int i){
		return PaymentType.intToPayment.get(i);
	}
}
